package com.service.order.config;

import com.sun.jndi.ldap.Ber;

import java.util.*;

public class Dome {

    public static void main(String[] args) {
        String[] nums = {"大王", "小王"
                , "梅花2", "梅花3", "梅花4", "梅花5", "梅花6", "梅花7", "梅花8", "梅花9", "梅花10", "梅花A", "梅花J", "梅花Q", "梅花K"
                , "方块2", "方块3", "方块4", "方块5", "方块6", "方块7", "方块8", "方块9", "方块10", "方块A", "方块J", "方块Q", "方块K"
                , "红心2", "红心3", "红心4", "红心5", "红心6", "红心7", "红心8", "红心9", "红心10", "红心A", "红心J", "红心Q", "红心K"
                , "黑桃2", "黑桃3", "黑桃4", "黑桃5", "黑桃6", "黑桃7", "黑桃8", "黑桃9", "黑桃10", "黑桃A", "黑桃J", "黑桃Q", "黑桃K"
        };
        String[] names = {"","张三", "李四", "王麻子"};

        Map<String, List<String>> map = new HashMap<>();
        List<Integer> numList = new ArrayList<>();
        for (; ; ) {
            int numbers = (int) (Math.random() * 54) + 1;
            if (!numList.contains(numbers)) {
                numList.add(numbers);
            }
            if (numList.size() >= 54) {
                break;
            }
        }

        int num = 0;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < numList.size() - 3; i++) {
            if (i % 17 == 0) {
                num++;
                if (num>3){
                    break;
                }
            }

            if (map.containsKey(names[num])) {
                List<String> str = map.get(names[num]);
                str.add(nums[numList.get(i) -1]);
                map.put(names[num], str);
            } else {
                List<String> str = new ArrayList<>();
                str.add(nums[numList.get(i)-1 ]);
                map.put(names[num], str);
            }



        }
        for (String s : map.keySet()) {
            System.out.println(s + "有:" + map.get(s));
        }

        System.out.println("地主牌是["+nums[numList.get(numList.size()-1)]+","+nums[numList.get(numList.size()-2)-1]+","+nums[numList.get(numList.size()-3)-1]+"]");
    }

}
